import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/layout/index.vue'
import NoteBook from '@/icons/NoteBook.vue'
import Meeting from '@/icons/Meeting.vue'
import PptxFilled from '@/icons/PptxFilled.vue'
import Apps from '@/icons/Apps.vue'
import Analysis from '@/icons/Analysis.vue'
import AiStudy from '@/icons/AiStudy.vue'

export const asyncRouters = {
  path: '/',
  component: Layout,
  redirect: '/platform',
  children: [
    {
      path: 'platform',
      component: () => import('@/views/landload/index.vue'),
      meta: {
        title: '智能体应用',
        hidden: true,
        style:{
          background: 'linear-gradient(to top, #f8f9fa, #edbb8f)',
        }
      },
    },
    {
      path: 'chat',
      component: () => import('@/views/chat/index.vue'),
      meta: {
        icon: 'ChatLineRound',
        title: '会话',
      },
    },
    {
      path: 'knowledge',
      component: () => import('@/views/knowledge/index.vue'),
      meta: {
        icon: 'Reading',
        title: '知识库',
      },
    },
    {
      path: 'my_knowledge',
      component: () => import('@/views/my_knowledge/index.vue'),
      meta: {
        icon: 'Collection',
        title: '资料库',
      },
    },
    {
      path: 'meeting',
      component: () => import('@/views/meeting/index.vue'),
      meta: {
        icon: Meeting,
        title: '会议',
      },
      redirect: '/meeting/record',
      children: [
        {
          path: 'record',
          component: () => import('@/views/meeting/record.vue'),
        },
        {
          path: 'add',
          component: () => import('@/views/meeting/add-or-edit-meeting.vue'),
        },
        {
          path: 'edit/:id',
          component: () => import('@/views/meeting/add-or-edit-meeting.vue'),
        },
        {
          path: 'ai/:id',
          component: () => import('@/views/meeting/ai-translate.vue'),
        },
      ],
    },
    {
      path: 'file',
      component: () => import('@/views/note/index.vue'),
      meta: {
        icon: NoteBook,
        title: '笔记',
      },
      redirect: '/file/note',
      children: [
        {
          path: 'note/:id*',
          // component: () => import('@/views/note/layout.vue'),
          component: () => import('@/views/note/noteList.vue'),
        },
        {
          path: 'doc/:docId',
          component: () => import('@/views/note/document-editor.vue'),
        },
        {
          path: 'mindmap/:mindmapId',
          component: () => import('@/views/note/addXmind.vue'),
        },
        {
          path: 'drawio/:drawioId',
          component: () => import('@/views/note/flow-chart.vue'),
        },
        {
          path: 'recycle',
          component: () => import('@/views/note/recycle.vue'),
        },
        {
          path: 'share',
          component: () => import('@/views/note/share.vue'),
        },
        {
          path: 'share-edit/:id',
          component: () => import('@/views/note/share-edit.vue'),
        },
        {
          path: 'graph',
          component: () => import('@/views/note/graph.vue'),
        },
        {
          path: 'note-space',
          component: () => import('@/views/note-space/index.vue'),
        },
        {
          path: 'note-detail/:id',
          component: () => import('@/views/note-space/note-detail.vue'),
        },
      ],
    },
    {
      path: 'my_application',
      component: () => import('@/views/my_application/index.vue'),
      meta: {
        icon: Apps,
        title: '应用',
      },
    },
    {
      path: 'ai-ppt',
      component: () => import('@/views/ai-pptx/index.vue'),
      meta: {
        icon: PptxFilled,
        title: 'AI PPT',
      },
      children: [
        {
          path: '',
          component: () => import('@/views/ai-pptx/home.vue'),
          meta: {
            title: '',
          },
        },
        {
          path: 'create/outline',
          component: () => import('@/views/ai-pptx/CreateOutline.vue'),
          meta: {
            title: '智能生成PPT',
          },
        },
        {
          path: 'choose-template',
          component: () => import('@/views/ai-pptx/template/index.vue'),
          meta: {
            title: 'PPT模板',
          },
        },
        {
          path: 'generate-outline',
          component: () => import('@/views/ai-pptx/outline/index.vue'),
          meta: {
            title: '智能大纲',
          },
        },
        {
          path: 'generate-ppt',
          component: () => import('@/views/ai-pptx/PptFile.vue'),
          meta: {
            title: 'PPT详情',
          },
        },
      ],
    },
    {
      path: 'my',
      component: () => import('@/views/my/index.vue'),
      meta: {
        title: '个人中心',
        hidden: true,
      },
    },
    {
      path: 'course',
      component: () => import('@/views/course-analysis/index.vue'),
      meta: {
        title: '课程解析',
        icon: Analysis,
      },
      redirect: '/course/list',
      children: [
        {
          path: 'list',
          component: () => import('@/views/course-analysis/list.vue'),
        },
        {
          path: 'transcripts/:id',
          component: () => import('@/views/course-analysis/transcripts.vue'),
        },
      ],
    },
    {
      path: 'study',
      component: () => import('@/views/study/index.vue'),
      meta: {
        title: '课程学习',
        icon: AiStudy,
      },
      redirect: '/study/project',
      children: [
        {
          path: 'project',
          component: () => import('@/views/study/course/index.vue'),
        },
        {
          path: 'data-items',
          component: () => import('@/views/study/data/index.vue'),
        },
        {
          path: 'exam',
          component: () => import('@/views/study/exam/index.vue'),
        },
        {
          path: 'chart',
          component: () => import('@/views/study/chart/index.vue'),
        },
        {
          path: 'node',
          component: () => import('@/views/study/chart/node.vue'),
        },
        {
          path: 'practice/:id',
          component: () => import('@/views/study/chart/practice.vue'),
        },
      ],
    },
  ],
}

const defaultRoutes = [
  {
    path: '/redirect',
    component: Layout,
    meta: {
      title: '',
      icon: '',
    },
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index.vue'),
      },
    ],
  },
  {
    path: '/404',
    component: () => import('@/views/404.vue'),
    meta: {
      title: '404',
    },
  },
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      title: '用户登录',
    },
  },
  {
    path: '/share-middle',
    component: () => import('@/views/note/share-middle.vue'),
    meta: {
      title: '笔记分享',
    },
  }
]

defaultRoutes.push(asyncRouters)

defaultRoutes.push({
  path: '/:catchAll(.*)',
  redirect: '/404',
  hidden: true,
})

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: defaultRoutes,
})

export default router
